<template>
  <div>
    <detail-banner
    :sightName="sightName"
    :bannerImg="bannerImg"
    :gallaryImgs="gallaryImgs"
    ></detail-banner>
    <detail-header></detail-header>
    <div class="content">
      <detail-list :list="list"></detail-list>
    </div>
    <div class="scroll"></div>
  </div>
</template>

<script>
import DetailBanner from './components/DetailBanner'
import DetailHeader from './components/DetailHeader'
import DetailList from './components/DetailList'
import axios from 'axios'
  export default {
    name:"Detail",
    data() {
      return {
        currentId:0,
        sightName:'',
        bannerImg:'',
        gallaryImgs:[],
        list:[]
      }
    },
    components:{
      DetailBanner,
      DetailHeader,
      DetailList
    },
    methods: {
      getDetailInfo() {
        axios.get('/api/detail',{
          params:{
            id:this.$route.params.id
          }
        }).then(this.getDetailInfoSuc)
      },
      getDetailInfoSuc(res){
        res=res.data
        if(res.ret&&res.data){
          const data=res.data
          this.sightName=data.sightName
          this.bannerImg=data.bannerImg
          this.gallaryImgs=data.gallaryImgs
          this.list=data.categoryList
        }
      }
    },
    mounted(){
      this.currentId=this.$route.params.id
      this.getDetailInfo()
    },
    activated(){
      if(this.currentId!==this.$route.params.id){
        this.currentId=this.$route.params.id
        this.getDetailInfo()
      }
    }
  }
</script>

<style lang="stylus" scoped>
.content

.scroll
  height 50rem
</style>